<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="125">
            <Row  class="query-form">
                <Col span="8">
                    <FormItem label="所属单位：">
                        <cascaderDom ref="queryOrgCascader" @setOrgInfo="setOrgId"
                                     :rootOrgId="companyId" class="query-form-el"
                                     :orgTree="true"></cascaderDom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="创建时间：" prop="content" >
                        <DatePicker class="query-form-el" v-model="dataToQuery.createDateRange" format="yyyy-MM-dd" type="daterange" placement="bottom-end" placeholder="请选择创建时间段"
                                    @on-change="(date) => onSelectFieldQueryDateRange(date, 'createDate')"	></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8" v-if="!switchFlag">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
                <Col span="8" v-else>
					<FormItem label="企业搜索：">
						<Input class="query-form-el" placeholder="输入公司名称" v-model="dataToQuery.orgName"></Input>
					</FormItem>
                    <!-- <FormItem label='正副处：'>
                        <Select v-model='dataToQuery.adminLevel' clearable class='query-form-el'>
                            <Option value="AD-000001000000001">正处</Option>
                            <Option value="AD-000001000000002">副处</Option>
                            <Option value="AD-000001000000003">副处以下</Option>
                        </Select>
                    </FormItem> -->
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                
                <Col span="8" :offset="16">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
               :loading='pageStatus.loading'
               border :columns="columns1" :data="dataTable">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>

    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                columns1: [
                    {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {key: 'companyName', title: '单位',fixed: 'left', align: 'center', minWidth: 200},
                    {key: 'twoLevelName', title: '所属二级集团', fixed: 'left', align: 'center', minWidth: 200},
                    // {key: 'levelName', title: '正副处', align: 'center', minWidth: 100},
                    {key: 'sa_company_envinfo', title: '企业信息', align: 'center', minWidth: 100},
                    {key: 'sa_staff_envinfo', title: '人员信息', align: 'center', minWidth: 100},
                    {key: 'sa_honor_statis', title: '工作荣誉', align: 'center', minWidth: 100},
                    {key: 'sa_security_engineer_pass_rate', title: '注册安全工程师', align: 'center', minWidth: 100},
                    {key: 'sa_std_standard', title: '安全标准化', align: 'center', minWidth: 100},
                    {title: '环保投入汇总表', align: 'center',
                        children: [
                            {key: 'en_rpt_investment', title: '本年度环保提升项目完成情况', align: 'center', minWidth: 100},
                            {key: 'en_rpt_investment_plan', title: '次年环保投入计划', align: 'center', minWidth: 100},
                        ] },
                    {key: 'en_rpt_investment_plan', title: '环保投入汇总表', align: 'center', minWidth: 100},
                    {key: 'en_rpt_annual', title: 'ESG环境报表', align: 'center', minWidth: 100},
                    {key: 'en_rpt_semi_annual', title: '环境信息报表', align: 'center', minWidth: 100},
                    {key: 'en_prd_audit_form', title: '清洁生产信息报送单', align: 'center', minWidth: 100},
                    {key: 'en_prd_evaluation_form', title: '审核综合考评汇总表', align: 'center', minWidth: 100},
                    {key: 'en_dsp_info', title: '排污许可证管理', align: 'center', minWidth: 100},
                    {key: 'en_rpt_performance_rating', title: '重点行业绩效评级报表', align: 'center', minWidth: 100},
                    {key: 'loginCount', title: '登录次数', align: 'center', minWidth: 100,render: (h, params) => {
                            return h('span', params.row.loginCount==null?0 :params.row.loginCount)
                        }},
                ],
                tableHeight: 10,
                companyId:'',
                buttonLoading:false,
                // api
                queryUrl: Api.counntStatistics,
            }
        },
        mounted() {
            this.companyId=sessionStorage('userId').getObject('userId').companyId
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            query() {
                if (this.dataToQuery.adminLevel != null && this.dataToQuery.adminLevel != undefined && this.dataToQuery.adminLevel.length < 1) {
                    this.dataToQuery.adminLevel=null
                }
                if (this.dataToQuery.companyId != null&&this.dataToQuery.companyId != undefined&&this.dataToQuery.companyId != '') {
                    this.dataToQuery.orgId=this.dataToQuery.companyId
                }else {
                    this.dataToQuery.orgId = sessionStorage('userId').getObject('userId').companyId
                }
                this.queryAjax();
            },
            setOrgId(data) {
                this.dataToQuery.companyId = data[data.length - 1];
            },
        },
        computed: {},

    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
</style>
